<template>
    <div id="app">
        <router-view v-if="isRouterAlive"/>
    </div>
</template>



<script>
import router from "@/router";
import sessionApi from "@/api/sessionApi"
import vuexApi from "@/api/vuexApi"

export default {
    name: 'app',
    data() {
        return {
            isRouterAlive: true
        }
    },
    provide() {
        return {
            reload: this.reload
        }
    },
    created() {
        //每次页面刷新的时候，判断是否动态路由规则已消失，如果消失那么从session中获取缓存重新走一遍putAuthList的逻辑
        if (router.options.routes.length < 3) {
            let authList = sessionApi.getAuthList()
            if (!authList) {
                router.push({path: "/login"});
            } else {
                vuexApi.putAuthList(authList)
            }
        }

        vuexApi.getDictMap()
    },
    methods: {
        reload() {
            this.isRouterAlive = false
            this.$nextTick(() => {
                this.isRouterAlive = true
            })
        }
    }
}
</script>

<style>
* {
    margin: 0;
    padding: 0;
}
</style>
